<html>
    <head>
        <meta charset="utf-8"></meta>
    </head>
<body >
    <textarea id="url" style="width: 300px;height: 100px;"></textarea>
    <input type="button" onclick="onSubmit()" value="提交">
    <div id="content">
        
    </div>
    <script src="https://cdn.socket.io/socket.io-1.4.4.js"></script>
    <script src="https://code.jquery.com/jquery-1.11.1.js"></script>
    <script>
    const socket = io('http://42.194.134.137:8088',{transports: ['websocket']});
    let d_count = 0;
    function onSubmit(){
        var url = $("#url").val(); 
        if(url==""){
            alert("url不能为空");
            return
        }
        d_count = 0;
        $("#content").html(``);
        url =  url.replace(/\n/g,',')
        socket.emit("submit", {url:url});
    }
    
    socket.on("submit",function(res){
        d_count++;
        if(res['code']==200){
            let url = res['url'];
            let content = res['content'];
            let whoisserver = res['whoisserver'];
            let end_time = res['end_time'];
            let count = res['count'];
            let ip = res['ip'];
            let d_time = res['d_time'];

            $("#content").append(`<p>第${d_count}域名，一共${count}---${url}----${whoisserver}----${ip}----单消耗${d_time}s;总消耗：${end_time}s</p><p>${content}</p>`);
            if(d_count == count){
                $("#content").append(`<p>全部完成，一共消耗${end_time}s</p>`);
            }
        }else{
            $("#content").append(`<p>第${d_count}域名----${res['msg']}</p>`);
        }
        
    });
    </script>
</body>
</html>